package com.dianrui.moonfire.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.dianrui.moonfire.R;


public class LoadingDialog extends Dialog {

    private Context mContext;
    private ProgressBar progressBar;
    private TextView textView;

    public LoadingDialog(Context context) {
        super(context, R.style.LoadingDialogTheme);
        this.mContext = context;
        setContentView(R.layout.loading_dialog);
        textView= findViewById(R.id.loading_msg);
        progressBar= findViewById(R.id.pb);
        Window window = getWindow();
        WindowManager windowManager = window.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = display.getWidth() * 2 / 5; // 设置dialog宽度为屏幕的2/5
        lp.height = display.getWidth() * 2 / 5; // 设置dialog宽度为屏幕的2/5
        window.setAttributes(lp);
    }

    public LoadingDialog setMessage(String message) {
        textView.setText(message);
        return this;
    }

}